package main

import (
	"bufio"
	"flag"
	"fmt"
	"io"
	"log"
	"os"
	"strings"
)

func convert2Note(s string) (string) {
	fmt.Println(s)
	if strings.Contains(s, "commentLine(") {
		s = strings.Replace(s, "commentLine(\"","", -1)
		s = strings.Replace(s, "\")","", -1)
	}
	if strings.Contains(s, "printMap") {
		return ""
	}
	return s
}

func main() {
	filename := "a.txt"
	f, _ := os.Create(filename)
	defer f.Close()

	var name string
	flag.StringVar(&name, "name", "hello.go", "go file name")
	flag.Parse()
	//fmt.Println(name)
	file, err := os.Open(name)
	if err != nil {
		log.Fatalf("open file failed: %s n", err.Error())
	}
	defer file.Close()
	reader := bufio.NewReader(file)
	i := 0
	for {
		line, _, err := reader.ReadLine()
		if err == io.EOF {
			break
		}
		i++
		s := string(line)
		s = convert2Note(s)
		f.WriteString(s+"\n")
	}
}
